package at.ac.tuwien.prog.memory;

import at.ac.tuwien.prog.entity.Register;

/**
 * wrapper for the memory with I/O-operations.
 * 
 * 16384 addressierbare Register zu je 32Bit/4Byte haben Adressen von -8192 bis 8191.
 * 
 * Die Recheneinheit operiert direkt auf den Registern.
 * Die ausgefuehrten Befehle liegen ebenfalls in den Registern.
 * Register -8192 enthaellt die Adresse des Registers mit dem naechsten Befehl (program counter).
 * 
 * @author christoph.pickl@student.tuwien.ac.at
 */
public interface IMemoryManager {

	/**
	 * writes given value to given address.
	 * 
	 * @param address of register where should be written to
	 * @param value 32 bit / 4 byte / 1 int
	 */
	void setRegisterValue(int address, Register value);
	
	/**
	 * 
	 * @param address
	 * @return
	 */
	Register getRegisterValue(int address);
	
	/**
	 * shortcut method for getRegisterValue(-8192).
	 * @return value of program counter register
	 */
	Register getProgramCounter();
	
	/**
	 * shortcut method for setRegisterValue(&programCounter, address).
	 * 
	 * @param address which should be written to PC
	 */
	void setProgramCounter(Register address);

	/**
	 * add listener for writes into display data segment.
	 * 
	 * @param listener which should be added to listeners
	 */
	void addDisplayDataListener(IDisplayDataListener listener);

	/**
	 * remove listener for writes into display data segment.
	 * 
	 * @param listener which should be removed from listeners
	 * @return true if was removed, false otherwise
	 */
	boolean removeDisplayDataListener(IDisplayDataListener listener);
	
}
